import request from '@/router/axios';

export const getList = (current, size, params) => {
  return request({
    url: '/api/rb-service/service/terminal/terminal/listV2',
    method: 'get',
    params: {
      ...params,
      current,
      size,
    }
  })
}

/* 商户终端列表 v2.0.0 */
export const getTerminalPage = (current, size, params) => {
  return request({
    // url: '/api/rb-service/service/terminal/terminal/incomingTerminalPage',
    url: '/api/rb-service/service/terminal/terminal/listV2',
    method: 'get',
    params: {
      ...params,
      current,
      size
    }
  })
}

/* 商户终端详情 v2.0.0 */
export const getDetail = (id) => {
  return request({
    // url: '/api/rb-service/service/terminal/terminal/detail',
    url: '/api/rb-service/service/terminal/terminal/detailV2',
    method: 'get',
    params: {
      id
    }
  })
}

/* 终端状态 禁用启用 */
export const incomingTerminalOn = (id, isOn) => {
  return request({
    url: '/api/rb-service/service/terminal/terminal/changeIsOn',
    method: 'get',
    params: {
      id,
      isOn
    }
  })
}

export const remove = (ids,payPwd) => {
  // export const remove = (ids) => {
  return request({
    url: '/api/rb-service/service/terminal/terminal/remove',
    method: 'post',
    params: {
      payPwd,
      ids
    }
  })
}

export const add = (row) => {
  return request({
    url: '/api/rb-service/service/terminal/terminal/submit',
    method: 'post',
    data: row
  })
}

export const update = (row) => {
  return request({
    url: '/api/rb-service/service/terminal/terminal/submit',
    method: 'post',
    data: row
  })
}

/* 新增 终端表单 V2.0.0 */
export const addTerminal = (params) => {
  return request({
    url: '/api/rb-service/service/terminal/terminal/submitV2',
    method: 'post',
    params: {
      ...params
    }
  })
}

/* 修改 终端表单 V2.0.0 */
export const editTerminal = (params) => {
  return request({
    url: '/api/rb-service/service/terminal/terminal/edit',
    method: 'post',
    params: {
      ...params
    }
  })
}

// 终端管理---类型编号
export const getRptNo = (current,size,params) => {
  return request({
    url: '/api/rb-service/service/terminal/terminal/typeList',
    method: 'get',
    params: {
      current,
      size,
      ...params
    }
  })
}

// 终端管理---供应商编号
export const getRpsNo = (current,size,params) => {
  return request({
    url: '/api/rb-service/service/terminal/terminal/supList',
    method: 'get',
    params: {
      current,
      size,
      ...params
    }
  })
}


// 终端管理---型号
export const getrpmNo = (current,size,params) => {
  return request({
    url: '/api/rb-service/service/terminal/terminal/modelList',
    method: 'get',
    params: {
      current,
      size,
      ...params
    }
  })
}

/* 终端管理-型号列表 v2.0.0 */
export const getModelList = (current,size,params) => {
  return request({
    url: '/api/rb-service/service/terminal/terminal/modelListV2',
    method: 'get',
    params: {
      current,
      size,
      ...params
    }
  })
}


// 终端管理---商户号
export const getrpiNo = (current,size,params) => {
  return request({
    url: '/api/rb-service/service/incomingbasic/incoming_basic/list',
    method: 'get',
    params: {
      current,
      size,
      rpiKind: 0,
      // rpiExStatus: 3,
      ...params
    }
  })
}

// 终端管理---门店
export const getstoreNo = (current,size,params) => {
  return request({
    url: '/api/rb-service/service/posStore/pos_store/listV2',
    method: 'get',
    params: {
      current,
      size,
      ...params
    }
  })
}

// 终端管理---操作员|收银员
export const getrpstNo = (current,size,params) => {
  return request({
    url: '/api/rb-service/service/posStaff/pos_staff/listV2',
    method: 'get',
    params: {
      current,
      size,
      ...params
    }
  })
}

// 设备管理---门店操作员树结构
export const storeAndMerchantTree = (rpiNo) => {
  return request({
    url: '/api/rb-service/service/terminal/terminal/storeAndMerchantTree',
    method: 'get',
    params: {
      rpiNo
    }
  })
}
// 设备管理---终端树结构
export const terminalTree = (rpiNo) => {
  return request({
    url: '/api/rb-service/service/terminal/terminal/terminalTree',
    method: 'get',
    params: {
      rpiNo
    }
  })
}
// 设备管理---新增或修改
export const equipmentSubmitEq = (row) => {
  return request({
    url: '/api/rb-service/service/terminal/terminal/submitEq',
    method: 'post',
    data: row
  })
}
// 设备管理---详情
export const detailEq = (id) => {
  return request({
    url: '/api/rb-service/service/terminal/terminal/detailEq',
    method: 'get',
    params: {
      id
    }
  })
}

export const queryModuleType = (rpmNo) => {
  return request({
      url: '/api/rb-service/service/terminal/terminal/queryModuleType',
      method: 'get',
      params: {rpmNo}
  })
}

/* 终端 导出 */
export const getExportzd = (params) => {
  return request({
    headers: {
      "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
    },
    responseType: 'blob',
    url: '/api/rb-service/service/terminal/terminal/export',
    method: 'get',
    params: {
      ...params,
    }
  })
}

/* 终端 导出模板 */
export const getExportTemplatezd = (params) => {
  return request({
    headers: {
      "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
    },
    responseType: 'blob',
    url: '/api/rb-service/service/terminal/terminal/export-template',
    method: 'get',
    params: {
      ...params,
    }
  })
}


/* 设备 导出 */
export const getExportsb = (params) => {
  return request({
    headers: {
      "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
    },
    responseType: 'blob',
    url: '/api/rb-service/service/terminal/terminal/export',
    method: 'get',
    params: {
      ...params,
    }
  })
}

/* 设备 导出模板 */
export const getExportTemplatesb = (params) => {
  return request({
    headers: {
      "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
    },
    responseType: 'blob',
    url: '/api/rb-service/service/terminal/terminal/export-template',
    method: 'get',
    params: {
      ...params,
    }
  })
}

/* 终端门店绑定列表 已绑定 */
export const getStoreBindTerminalPage = (current, size, storeNo, params) => {
  return request({
    url: '/api/rb-service/service/terminal/terminal/storeBindTerminalPage',
    method: 'get',
    params: {
      ...params,
      current,
      size,
      storeNo
    }
  })
}

/* 终端门店绑定列表 未绑定 */
export const getStoreUNBindTerminalPage = (current, size, storeNo, params) => {
  return request({
    url: '/api/rb-service/service/terminal/terminal/storeUNBindTerminalPage',
    method: 'get',
    params: {
      ...params,
      current,
      size,
      storeNo
    }
  })
}

/* 终端收银员绑定列表 已绑定 */
export const getStaffBindTerminalPage = (current, size, rpstNo, params) => {
  return request({
    url: '/api/rb-service/service/terminal/terminal/staffBindTerminalPage',
    method: 'get',
    params: {
      ...params,
      current,
      size,
      rpstNo
    }
  })
}

/* 终端门店绑定列表 未绑定 */
export const getStaffUNBindTerminalPage = (current, size, rpstNo, params) => {
  return request({
    url: '/api/rb-service/service/terminal/terminal/staffUNBindTerminalPage',
    method: 'get',
    params: {
      ...params,
      current,
      size,
      rpstNo
    }
  })
}

/* 终端绑定确认 */
export const staffBindTerminal = (rpsNo, rpstNo, rtNo) => {
  return request({
    url: '/api/rb-service/service/terminal/terminal/staffBindTerminal',
    method: 'get',
    params: {
      rpsNo,
      rpstNo,
      rtNo
    }
  })
}

/* 终端解绑 */
export const staffUNBindTerminal = (params) => {
  return request({
    url: '/api/rb-service/service/terminal/terminal/staffUNBindTerminal',
    method: 'get',
    params: {...params}
  })
}

/* 终端管理获取数量 */
export const groupCount = (params) => {
  return request({
    url: '/api/rb-service/service/terminal/terminal/groupCount',
    method: 'get',
    params: {...params}
  })
}


export const getServiceList = (params) => {
  return request({
    url: '/api/rb-service/service/serviceinfo/service_info/list',
    method: 'get',
    params: {
      current: -1,
      size: -1,
      serviceAuditStatus: 2,
      ...params
    }
  })
}

/* 终端管理 导出 */
export const getExport = (params) => {
  return request({
    headers: {
      "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
    },
    responseType: 'blob',
    url: '/api/rb-service/service/terminal/terminal/export',
    method: 'get',
    params: {
      ...params,
    }
  })
}

/* 终端管理 导出模板 */
export const getExportTemplate = (params) => {
  return request({
    headers: {
      "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
    },
    responseType: 'blob',
    url: '/api/rb-service/service/terminal/terminal/export-template',
    method: 'get',
    params: {
      ...params,
    }
  })
}

/* 根据sn获取库存 */
export const queryStoreBySn = (params) => {
  return request({
    url: '/api/rb-service/service/terminal/terminal/queryStoreBySn',
    method: 'get',
    params: {
      ...params
    }
  })
}

// 解绑设备 扫码设备
export const removeSM = (row) => {
  return request({
    url: '/api/rb-service/service/terminal/terminal/unBindCodeScan',
    method: 'post',
    data: row
  })
}

// 解绑设备 POS设备
export const removePOS = (row) => {
  return request({
    url: '/api/rb-service/service/terminal/terminal/unBindYSPOS',
    method: 'post',
    data: row
  })
}

// 解绑设备 智能机设备
export const unBindZNJ = (row) => {
  return request({
    url: '/api/rb-service/service/terminal/terminal/unBindIntelligentMac',
    method: 'post',
    data: row
  })
}